<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Repair a string using an optionally provided configuration file</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="tidy.repairfile.html">« tidy::repairFile</a></li>
      <li style="float: right;"><a href="tidy.root.html">tidy::root »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.tidy.html">tidy</a></li>
    <li>Repair a string using an optionally provided configuration file</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="tidy.repairstring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">tidy::repairString</h1>
  <h1 class="refname">tidy_repair_string</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8, PECL tidy &gt;= 0.7.0)</p><p class="refpurpose"><span class="refname">tidy::repairString</span> -- <span class="refname">tidy_repair_string</span> &mdash; <span class="dc-title">Repair a string using an optionally provided configuration file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-tidy.repairstring-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>tidy::repairString</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><span class="type">array</span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$config</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>tidy_repair_string</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><span class="type">array</span>|<span class="type">string</span>|<span class="type">null</span></span> <code class="parameter">$config</code><span class="initializer"> = <strong><code>null</code></strong></span></span>, <span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Repairs the given string.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-tidy.repairstring-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">string</code></dt>

     <dd>

      <p class="para">
       The data to be repaired.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">config</code></dt>

     <dd>

      <p class="para">
       The config <code class="parameter">config</code> can be passed either as an
       array or as a string. If a string is passed, it is interpreted as the
       name of the configuration file, otherwise, it is interpreted as the
       options themselves.
      </p>
      <p class="para">
       Check <a href="http://api.html-tidy.org/#quick-reference" class="link external">&raquo;&nbsp;http://api.html-tidy.org/#quick-reference</a> for
       an explanation about each option.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">encoding</code></dt>

     <dd>

      <p class="para">
       The <code class="parameter">encoding</code> parameter sets the encoding for
       input/output documents. The possible values for encoding  are: 
       <code class="literal">ascii</code>, <code class="literal">latin0</code>, <code class="literal">latin1</code>,
       <code class="literal">raw</code>, <code class="literal">utf8</code>, <code class="literal">iso2022</code>,
       <code class="literal">mac</code>, <code class="literal">win1252</code>, <code class="literal">ibm858</code>,
       <code class="literal">utf16</code>, <code class="literal">utf16le</code>, <code class="literal">utf16be</code>,
       <code class="literal">big5</code>, and <code class="literal">shiftjis</code>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-tidy.repairstring-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the repaired string,  或者在失败时返回 <strong><code>false</code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-tidy.repairstring-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <span class="methodname"><strong>tidy::repairString()</strong></span> is a static method now.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">config</code> and <code class="parameter">encoding</code> are nullable now.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       This function no longer accepts the <code class="parameter">useIncludePath</code> parameter.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-tidy.repairstring-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3807">
    <p><strong>示例 #1 <span class="function"><strong>tidy::repairString()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />ob_start</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;<br /></span><br />&lt;html&gt;<br />&nbsp;&nbsp;&lt;head&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;test&lt;/title&gt;<br />&nbsp;&nbsp;&lt;/head&gt;<br />&nbsp;&nbsp;&lt;body&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;error&lt;/i&gt;<br />&nbsp;&nbsp;&lt;/body&gt;<br />&lt;/html&gt;<br /><br /><span style="color: #0000BB">&lt;?php<br /><br />$buffer&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ob_get_clean</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$tidy&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">tidy</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$clean&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$tidy</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">repairString</span><span style="color: #007700">(</span><span style="color: #0000BB">$buffer</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$clean</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 3.2//EN&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;error&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-tidy.repairstring-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="tidy.parsefile.html" class="function" rel="rdfs-seeAlso">tidy::parseFile()</a> - Parse markup in file or URI</span></li>
   <li class="member"><span class="function"><a href="tidy.parsestring.html" class="function" rel="rdfs-seeAlso">tidy::parseString()</a> - Parse a document stored in a string</span></li>
   <li class="member"><span class="function"><a href="tidy.repairfile.html" class="function" rel="rdfs-seeAlso">tidy::repairFile()</a> - Repair a file and return it as a string</span></li>
  </ul>
 </div>

</div></div></div></body></html>